﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ExaminationTT.Model;

namespace ExaminationTT.View
{
    public partial class ExamDateScheduler : Form
    {
        private IExam _exam;
        public ExamDateScheduler(IExam exam)
        {
            _exam = exam;
            InitializeComponent();
            _txtBox_ExamDate.Text = _exam.ExamDate.ToString("dddd, dd MMMM yyyy");
            _dtp_ExambeginTime.Value = _exam.ExamDate;
            _dtp_examEndTime.Value = _exam.ExamEndDate;
        }

        private void _btn_Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;

        }

        private void _btn_OK_Click(object sender, EventArgs e)
        {
            if (_dtp_ExambeginTime.Value >= _dtp_examEndTime.Value)
            {
                MessageBox.Show("Foram inseridas horas inválidas", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            _exam.ExamDate = _dtp_ExambeginTime.Value;
            _exam.ExamEndDate = _dtp_examEndTime.Value;
            this.DialogResult = DialogResult.OK;

        }
    }
}
